package com.sh.caryr.erp.util;

import com.sh.caryr.erp.entity.enums.OrderStatus;

import java.util.HashMap;
import java.util.Map;

public class OrderUtil {

    private static Map<String, Integer> JDStatusMapping;

    // Order State
    //  1）WAIT_SELLER_STOCK_OUT 等待出库
    //  2）WAIT_GOODS_RECEIVE_CONFIRM 等待确认收货
    // X3）WAIT_SELLER_DELIVERY等待发货（只适用于海外购商家，含义为“等待境内发货”标签下的订单,非海外购商家无需使用）
    // X4) POP_ORDER_PAUSE POP暂停
    //  5）FINISHED_L 完成
    // X6）TRADE_CANCELED 取消
    // X7）LOCKED 已锁定
    // X8）WAIT_SEND_CODE 等待发码（LOC订单特有状态）
    public static Integer convertJDStatus(String jdTradeStatus) {
        if (JDStatusMapping == null) {
            JDStatusMapping = new HashMap<>();
            JDStatusMapping.put(JDOrderStatus.WAIT_DELIVER, OrderStatus.WAIT_DELIVER.getValue()); //等待出库
            JDStatusMapping.put(JDOrderStatus.WAIT_RECEIVE, OrderStatus.WAIT_RECEIVE.getValue()); //等待确认收货
            JDStatusMapping.put(JDOrderStatus.SUCCESS, OrderStatus.SUCCESS.getValue()); //完成
        }
        return JDStatusMapping.get(jdTradeStatus);
    }

    public static class JDOrderStatus {
        static String WAIT_DELIVER = "WAIT_SELLER_STOCK_OUT"; //等待出库
        static String WAIT_RECEIVE = "WAIT_GOODS_RECEIVE_CONFIRM"; //等待确认收货
        static String SUCCESS = "FINISHED_L"; //完成
    }
}
